import sys
import os
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import torch
import yaml
import cv2
from modules.xfeat import XFeat
from evaluation.dual_softmax_matcher import DualSoftMaxMatcher
from evaluation.alike.gl3d_pose_est_mnn import GL3DPoseMNNBenchmark
from evaluation.alike.superpoint import SuperPoint


def get_best_device(verbose = False):
    device = torch.device('cpu')
    if torch.cuda.is_available():
        device = torch.device('cuda')
    elif torch.backends.mps.is_available():
        device = torch.device('mps')
    else:
        device = torch.device('cpu')
    if verbose: print (f"Fastest device found is: {device}")
    return device


if __name__ == "__main__":
    config = {
            'nms_radius': 5,
            'keypoint_threshold': 0.005,
            'max_keypoints': 4096}

    # model = XFeat(weights=weight_path)
    model = SuperPoint(config).cuda()
    matcher = DualSoftMaxMatcher()
    mega_1500 = GL3DPoseMNNBenchmark(data_root="/media/liyuke/share/GL3D/")
    mega_1500.benchmark(desc_model = model,matcher_model = matcher)